package com.fattyCorps.common.mgr;

import com.fattyCorps.common.obj.config.GlobalMould;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

@Component
public class GlobalConfig {

    private HashMap<String, String> globalConfigMap = new HashMap<>();

//    public static final String STAR_LV = "star_lv";
//    public static final String MAX_STAR = "max_star";
    public static final String ONE_LOTTERY_COIN = "one_lottery_coin";
    public static final String TEN_LOTTERY_COIN = "ten_lottery_coin";
    public static final String FREE_LOTTERY_TIME = "free_lottery_time";
    public static final String ONE_HERO_FRAGMENT_NUM = "one_hero_fragment_num";
    public static final String EXP_ITEM_TYPE_ID = "exp_item_type_id";
//    public static final String STAR_STONE_ITEM_TYPE_ID = "star_stone_item_type_id";
    public static final String LOTTERY_ITEM_TYPE_ID = "lottery_item_type_id";

    public static final String PLAYER_INIT_ITEMS = "player_init_items";
    public static final String PLAYER_INIT_HEAD = "player_init_head";
    public static final String PLAYER_INIT_LV = "player_init_lv";
    public static final String PLAYER_INIT_COIN = "player_init_coin";
    public static final String PLAYER_INIT_GUANQIA = "player_init_guanqia";
    public static final String MAX_BATTLE_GROUP_HERO_NUM = "max_battle_group_hero_num";
    public static final String MAX_BATTLE_GROUP_FRONT_HERO_NUM = "max_battle_group_front_hero_num";
    public static final String MAX_BATTLE_GROUP_BACK_HERO_NUM = "max_battle_group_back_hero_num";
    public static final String MAX_BATTLE_ROUND_NUM = "max_battle_round_num";
    public static final String SKILL_ENERGY = "skill_energy";
    public static final String INIT_ENERGY = "init_energy";
    public static final String ATTACKED_ADD_ENERGY = "attacked_add_energy";
    public static final String ATTACK_ADD_ENERGY = "attack_add_energy";
    public static final String UPGRADE_STAR_ADD_ALL_PROP_PER = "upgrade_star_add_all_prop_per";
    public static final String DEFAULT_NOR_ATT_DISPLAY_ID = "default_nor_att_display_id";
    public static final String HANG_TIME_MAX = "hang_time_max";

    /////////// 战力相关
    // 攻击战力计算系数
    public static final String COMBAT_COEF_ATT = "combat_coef_att";
    // 暴击战力计算系数
    public static final String COMBAT_COEF_CRITICAL = "combat_coef_critical";
    // 防御战力计算系数
    public static final String COMBAT_COEF_DEF = "combat_coef_def";
    // 血量战力计算系数
    public static final String COMBAT_COEF_MAX_HP = "combat_coef_max_hp";
    // 减伤战力计算系数
    public static final String COMBAT_COEF_REDUCE_DAMAGE = "combat_coef_reduce_damage";
    // 速度战力计算系数
    public static final String COMBAT_COEF_SPEED = "combat_coef_speed";
    // 技能伤害战力计算系数
    public static final String COMBAT_COEF_SKILL_DAMAGE = "combat_coef_skill_damage";
    // 格挡战力计算系数
    public static final String COMBAT_COEF_PARRY = "combat_coef_parry";
    // 精准战力计算系数
    public static final String COMBAT_COEF_PRECISE = "combat_coef_precise";
    // 破甲战力计算系数
    public static final String COMBAT_COEF_ARMORBREAK = "combat_coef_armorBreak";
    // 免控战力计算系数
    public static final String COMBAT_COEF_IMMUNITY_CONTROL = "combat_coef_immunity_control";
    // 神圣战力计算系数
    public static final String COMBAT_COEF_SACRED_DAMAGE = "combat_coef_sacred_damage";


    public String getStringValue(String name){
        return globalConfigMap.get(name);
    }

    public Integer getIntValue(String name){
        return Integer.valueOf(globalConfigMap.get(name));
    }

    public void init(Cfg cfg) {
        List<GlobalMould> cfgAll = cfg.getCfgAll(GlobalMould.class);

        for (int i=0; i<cfgAll.size(); i++){
            GlobalMould globalMould = cfgAll.get(i);
            globalConfigMap.put(globalMould.getName(), globalMould.getValue());
        }
    }
}
